package com.tin.tinpicturebackend.exception;

/*
 * 异常处理工具类
 * */
public class ThrowUtils {

    public static void throwIf(boolean condition, RuntimeException runtimeException) {
        if (condition) {
            throw runtimeException;
        }
    }

    public static void throwIf(boolean condition, ErrorCode errorCode) {
        throwIf(condition, new BusinessException(errorCode));
//        if (condition){
//            throw new BusinessException(errorCode);
//        }
    }

    public static void throwIf(boolean condition, ErrorCode errorCode, String message) {
        throwIf(condition, new BusinessException(errorCode, message));
//        if (condition){
//            throw new BusinessException(errorCode,message);
//        }
    }
}
